1. Field of the Invention
The present invention relates to an imaging apparatus, a focus position detecting method, and a computer program product.
2. Description of the Related Art
In general, imaging apparatuses, such as digital still cameras, have an autofocus (hereinafter, referred to as “AF”) function of automatically bringing an object into focus. As a method of controlling an AF operation, hill-climbing AF control has been widely known (for example, see Japanese Patent Application Publication (Kokoku) No. 39-005265). In the hill-climbing AF control, the integrated value of the brightness difference between neighboring pixels is calculated from image data output from an imaging device and the integrated value of the brightness difference is used as an AF evaluation value indicating the degree of focus. When the object is in focus, the contour of the object is clear and the brightness difference between neighboring pixels increases, which results in an increase in the AF evaluation value. On the other hand, when the object is out of focus, the contour of the object is unclear and the brightness difference between neighboring pixels decreases, which results in a reduction in the AF evaluation value. During the AF operation, the focus lens is moved in the optical axis direction and the AF evaluation value is sequentially acquired. A position where the AF evaluation value is the maximum, that is, a peak position is used as a focus position and the focus lens stops at the focus position.
In recent years, as a technique of the digital still camera, an object tracking function for tracking a main object in the image has been put into practical use. The object tracking function detects the amount of movement and moving direction of the object using, for example, template matching in which the image data of an object image, which is a tracking target, is used as a template, moves an area (hereinafter, referred to as an “AF area”) to be subjected to the AF operation so as to track a moving object with the movement of the object, and performs the AF operation or calculates exposure conditions (for example, see Japanese Patent Application Laid-open No. 2009-175442 and Japanese Patent Application Laid-open No. H4-158322).
The imaging apparatus with the object tracking function according to the related art can move the AF area to follow the movement of the object. However, in the imaging apparatus, for example, when the object moves in the depth direction (a direction close to the photographer or a direction away from the photographer) of the image, the focus position is likely to be lost during the AF operation. That is, when the AF operation is performed using the position of the object, which is a tracking target, as an AF area, the movement range of the focus lens for acquiring an AF evaluation value is limited in order to perform the AF operation at a high speed considering the movement of the object. In this case, when the object moves in the depth direction of the image, the focus position of the object is disposed beyond the movement range of the focus lens. As a result, the focus position is likely to be lost.